public class _86 {
    static class Solution {
        public ListNode partition(ListNode head, int x) {
            ListNode first = new ListNode();
            ListNode secode = new ListNode();
            ListNode p = first;
            ListNode q = secode;
            while(head!=null){
                if(head.val < x){
                    p.next = head;
                    p = p.next;
                }else{
                    q.next = head;
                    q = q.next;
                }
                head = head.next;
            }
            p.next = secode.next;
            q.next = null;
            return first.next;
        }
    }
}
